*************************
**** Balance Test  ******
*************************

* to do the holm correction: order p-values lowest to highest
* multiply lowest by 8
* multiply second lowest by 7
* multiply third lowest by 6
* multiply fourth lowest by 5
* (see the notes document)

clear all
set more off

use "/Users/yasenov/Desktop/replication package/master.dta"


******* WITH MAJOR FIXED EFFECTS - TABLE 3
encode major_code, gen(major_v)

eststo: reghdfe male starttime SDstarttime, absorb(classroom_group major_v) cluster(student_id_group)
eststo: reghdfe age starttime SDstarttime, absorb(classroom_group major_v) cluster(student_id_group)
eststo: reghdfe native_eth starttime SDstarttime, absorb(classroom_group major_v) cluster(student_id_group)
eststo: reghdfe prescore starttime SDstarttime, absorb(classroom_group major_v) cluster(student_id_group)

label var starttime "Start Time"
label var SDstarttime "$\sigma$(Start Time)"

esttab using "BalanceTest.tex", replace label nonotes ///
	order(starttime SDstarttime) keep(starttime SDstarttime) nonum ///
	obslast star(* 0.10 ** 0.05 *** 0.01) se(3) b(3) nogaps ///   
    mtitles("\begin{tabular}{@{}c@{}}Indicator for \\ Male \end{tabular}" "\begin{tabular}{@{}c@{}} \\ Age \end{tabular}" "\begin{tabular}{@{}c@{}}Native \\ Ethnicity \end{tabular}" "\begin{tabular}{@{}c@{}} Pre-Collegiate \\ Score \end{tabular}" "\begin{tabular}{@{}c@{}} STEM \\ courses \end{tabular}" "\begin{tabular}{@{}c@{}}9am top \\ coding \end{tabular}")

	
****** WITHOUT MAJOR FIXED EFFECTS	- TABLE A1
eststo clear
eststo: reghdfe male starttime SDstarttime, absorb(classroom_group) cluster(student_id_group)
eststo: reghdfe age starttime SDstarttime, absorb(classroom_group) cluster(student_id_group)
eststo: reghdfe native_eth starttime SDstarttime, absorb(classroom_group) cluster(student_id_group)
eststo: reghdfe prescore starttime SDstarttime, absorb(classroom_group) cluster(student_id_group)

label var starttime "Start Time"
label var SDstarttime "$\sigma$(Start Time)"

esttab using "BalanceTest_no_major_fe.tex", replace label nonotes ///
	order(starttime SDstarttime) keep(starttime SDstarttime) nonum ///
	obslast star(* 0.10 ** 0.05 *** 0.01) se(3) b(3) nogaps ///   
    mtitles("\begin{tabular}{@{}c@{}}Indicator for \\ Male \end{tabular}" "\begin{tabular}{@{}c@{}} \\ Age \end{tabular}" "\begin{tabular}{@{}c@{}}Native \\ Ethnicity \end{tabular}" "\begin{tabular}{@{}c@{}} Pre-Collegiate \\ Score \end{tabular}" "\begin{tabular}{@{}c@{}} STEM \\ courses \end{tabular}" "\begin{tabular}{@{}c@{}}9am top \\ coding \end{tabular}")
